package com.study.zzedu.bean;

import android.view.View;
import android.widget.TextView;


import com.study.zzedu.R;
import com.study.zzedu.widget.bean.TreeNode;
import com.study.zzedu.widget.bean.TreeViewBinder;

/**
 * RootViewBinder
 *
 * @author 林zero
 * @date 2018/1/17
 */

public class HeadViewBinder extends TreeViewBinder<HeadViewBinder.ViewHolder> {
    @Override
    public int getLayoutId() {
        return R.layout.item_head_grade;
    }

    @Override
    public int getToggleId() {
        return R.id.ivNode;
    }

    @Override
    public int getCheckedId() {
        return 0;
    }

    @Override
    public int getClickId() {
        return R.id.ivName;
    }

    @Override
    public int getTypeId() {
        return 0;
    }

    @Override
    public ViewHolder creatViewHolder(View itemView) {
        return new ViewHolder(itemView);
    }

    @Override
    public void bindViewHolder(ViewHolder holder, int position, TreeNode treeNode) {
        ((TextView) holder.findViewById(R.id.tvTitle)).setText(((HeadNodeGrade) treeNode.getValue()).getTerm());
        String termIndex = termSwitch(((HeadNodeGrade) treeNode.getValue()).getIndex());
        ((TextView) holder.findViewById(R.id.tvIndex)).setText("第"+termIndex+"学期");
//        holder.findViewById(R.id.ivNode).setRotation(treeNode.isExpanded() ? 90 : 0);
//        //((ImageView) holder.findViewById(R.id.ivCheck)).setImageResource(treeNode.isChecked() ? R.drawable.ic_checked : R.drawable.ic_uncheck);
//        holder.findViewById(R.id.llParent).setBackgroundColor(holder.itemView.getContext().getResources().getColor(treeNode.isChecked() ? R.color.gray : R.color.white));
    }

    private String termSwitch(String index) {
        switch (index){
            case "1":return "一";
            case "2":return "二";
            case "3":return "三";
            case "4":return "四";
            case "5":return "五";
            case "6":return "六";
            case "7":return "七";
            case "8":return "八";
            case "9":return "九";
            case "10":return "十";
        }
        return "一";
    }

    class ViewHolder extends TreeViewBinder.ViewHolder {

        public ViewHolder(View itemView) {
            super(itemView);
        }
    }
}
